﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using Maticsoft.Common;
using LTP.Accounts.Bus;
using DQYT.HTDZ.Model;
using DQYT.HTDZ.BLL;

namespace DQYT.HTDZ.Web.FUJIAN
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsDecimal(txtID.Text))
			{
				strErr+="ID格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtATTACHID.Text))
			{
				strErr+="ATTACHID格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtOBJECTID.Text))
			{
				strErr+="OBJECTID格式错误！\\n";	
			}
			if(this.txtOBJECTTYPE.Text.Trim().Length==0)
			{
				strErr+="OBJECTTYPE不能为空！\\n";	
			}
			if(this.txtATTACHNAME.Text.Trim().Length==0)
			{
				strErr+="ATTACHNAME不能为空！\\n";	
			}
			if(this.txtATTACHURL.Text.Trim().Length==0)
			{
				strErr+="ATTACHURL不能为空！\\n";	
			}
			if(this.txtATTACHTYPE.Text.Trim().Length==0)
			{
				strErr+="ATTACHTYPE不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtATTACHSIZE.Text))
			{
				strErr+="ATTACHSIZE格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUPLOADTIME.Text))
			{
				strErr+="UPLOADTIME格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			decimal ID=decimal.Parse(this.txtID.Text);
			decimal ATTACHID=decimal.Parse(this.txtATTACHID.Text);
			decimal OBJECTID=decimal.Parse(this.txtOBJECTID.Text);
			string OBJECTTYPE=this.txtOBJECTTYPE.Text;
			string ATTACHNAME=this.txtATTACHNAME.Text;
			string ATTACHURL=this.txtATTACHURL.Text;
			string ATTACHTYPE=this.txtATTACHTYPE.Text;
			byte[] ATTACHBYTES= new UnicodeEncoding().GetBytes(this.txtATTACHBYTES.Text);
			decimal ATTACHSIZE=decimal.Parse(this.txtATTACHSIZE.Text);
			DateTime UPLOADTIME=DateTime.Parse(this.txtUPLOADTIME.Text);

			FUJIANModel model=new FUJIANModel();
			model.ID=ID;
			model.ATTACHID=ATTACHID;
			model.OBJECTID=OBJECTID;
			model.OBJECTTYPE=OBJECTTYPE;
			model.ATTACHNAME=ATTACHNAME;
			model.ATTACHURL=ATTACHURL;
			model.ATTACHTYPE=ATTACHTYPE;
			model.ATTACHBYTES=ATTACHBYTES;
			model.ATTACHSIZE=ATTACHSIZE;
			model.UPLOADTIME=UPLOADTIME;

			FUJIANBLL bll=new FUJIANBLL();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
